Skip to content

feat: Add GitHub Action to validate PR contributions#96

Merged
amanintech merged 2 commits into
mainfrom
add-pr-validation-workflow
Mar 25, 2026
Merged

feat: Add GitHub Action to validate PR contributions#96
amanintech merged 2 commits into
mainfrom
add-pr-validation-workflow

Conversation

@amanintech

@amanintech amanintech commented Mar 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds .github/workflows/validate-pr.yml — a GitHub Action that automatically validates incoming feat: PRs
  • Runs 4 checks on every new contribution:
    1. No edits to existing projectsfeat: PRs should only add new kits/bundles/templates
    2. Required root files — validates config.json, README.md, flows/ etc. based on contribution type (kit, bundle, or template)
    3. Flow folder structure — each flow subdirectory must have config.json, inputs.json, meta.json, README.md
    4. Outside-dir warning — flags changes to files outside kits/bundles/templates
  • Results posted to GitHub Actions job summary with a pass/fail table and detailed error messages

Test plan

  • Open a test PR with feat: title adding a valid kit → workflow should pass all checks
  • Open a test PR with feat: title modifying an existing kit → check 1 should fail
  • Open a test PR with a kit missing flows/ → check 2 should fail
  • Open a test PR with a flow missing meta.json → check 3 should fail
  • Verify job summary markdown renders correctly in Actions UI
  • Verify PRs without feat: in the title skip this workflow entirely

🤖 Generated with Claude Code

Summary

Adds a new GitHub Actions workflow (.github/workflows/validate-pr.yml) that validates PR contributions automatically.

Workflow behavior:

  • Triggers on PRs with titles starting with "feat:"
  • Compares changes against the merge-base of the target branch

Validation checks:

  1. Ensures PRs don't modify existing projects (new kits/bundles/templates only)
  2. Validates required root files exist (config.json, README.md, flows/, etc.)
  3. Verifies each flow subdirectory contains required files (config.json, inputs.json, meta.json, README.md)
  4. Warns about changes outside recognized project directories

Output:

  • Posts formatted results table and error/warning details to GitHub Actions job summary
  • Fails the job if validation errors are found

Adds a workflow that triggers on feat: PRs and runs 4 checks:
1. No modifications to existing kits/bundles/templates
2. Required root files present (config.json, README.md, flows/, etc.)
3. Each flow subdirectory has config.json, inputs.json, meta.json, README.md
4. Warns on changes outside contribution directories

Results are posted to the GitHub Actions job summary with a pass/fail table.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Introduces a new GitHub Actions workflow that validates pull requests with feat: prefix. The workflow checks contributed kits, bundles, and templates for required files, directory structure, and prevents modifications to existing projects.

Changes

Cohort / File(s) Summary
PR Validation Workflow
.github/workflows/validate-pr.yml
New GitHub Actions workflow (+319 lines) that validates contributions to kits, bundles, and templates. Implements four checks: prevents edits to existing projects, verifies required root files and directory structure, validates flow folder contents, and warns about changes outside contribution directories. Outputs validation results and errors to GitHub step summary.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Add GitHub Action to validate PR contributions' directly and clearly summarizes the main change: adding a new GitHub Actions workflow for PR validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-pr-validation-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/validate-pr.yml (2)

63-72: Hardcoded bundles/sample handling is fragile.

The special case for bundles/sample at line 68 won't scale if other nested bundle directories are added. Consider a more generic approach that detects nested structures.

♻️ Suggested improvement
             elif [[ "$file" == bundles/* ]]; then
-              # bundles/<bundle-name>/... → 2 levels
-              # Handle nested bundles like bundles/sample/chatbot
-              local second
-              second=$(echo "$file" | cut -d/ -f2)
-              if [ "$second" = "sample" ]; then
-                echo "$file" | cut -d/ -f1-3
-              else
-                echo "$file" | cut -d/ -f1-2
-              fi
+              # bundles/<bundle-name>/... → 2 levels by default
+              # For nested bundles, check if second-level dir contains config.json
+              local base_path
+              base_path=$(echo "$file" | cut -d/ -f1-2)
+              local nested_path
+              nested_path=$(echo "$file" | cut -d/ -f1-3)
+              # If nested path has config.json, treat as nested bundle
+              if [ -f "$nested_path/config.json" ]; then
+                echo "$nested_path"
+              else
+                echo "$base_path"
+              fi

Alternatively, document the bundles/sample convention if it's intentional.


44-55: Consider documenting the SKIP_PATHS exceptions.

The hardcoded SKIP_PATHS array allows bypassing validation for specific projects. While this provides necessary flexibility for existing non-conforming projects, consider adding a comment explaining why each path is skipped, or documenting these exceptions in CONTRIBUTING.md.

           # Known exceptions to skip
+          # - templates/indexation: Pre-existing template with legacy structure
+          # - kits/agentic/stock-analysis: Pre-existing kit with legacy structure
           SKIP_PATHS=("templates/indexation" "kits/agentic/stock-analysis")

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4eb88517-9c32-4322-b016-563e7ae9995a

📥 Commits

Reviewing files that changed from the base of the PR and between cd0d519 and 02d0384.

📒 Files selected for processing (1)
  • .github/workflows/validate-pr.yml

Comment on lines +137 to +149
case "$ptype" in
kit)
for req in config.json README.md; do
if [ ! -f "$project_path/$req" ]; then
ERRORS+=("Missing $req in $project_path")
CHECK2_PASS=false
fi
done
if [ ! -d "$project_path/flows" ]; then
ERRORS+=("Missing flows/ directory in $project_path")
CHECK2_PASS=false
fi
;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check what files existing kits actually contain to determine the baseline
echo "=== Checking file patterns in existing kits ==="
for kit_dir in kits/*/*/; do
  if [ -d "$kit_dir" ]; then
    echo "Kit: $kit_dir"
    ls -la "$kit_dir" 2>/dev/null | head -15
    echo "---"
  fi
done | head -100

Repository: Lamatic/AgentKit

Length of output: 5140


🏁 Script executed:

#!/bin/bash
# Check for package.json and .env.example across all kits
echo "=== Checking for package.json and .env.example in all kits ==="
echo ""
for kit_path in kits/*/*/; do
  if [ -d "$kit_path" ]; then
    kit_name=$(basename "$kit_path")
    has_package_json=""
    has_env_example=""
    has_config=""
    has_readme=""
    has_flows=""
    
    [ -f "$kit_path/package.json" ] && has_package_json=""
    [ -f "$kit_path/.env.example" ] && has_env_example=""
    [ -f "$kit_path/config.json" ] && has_config=""
    [ -f "$kit_path/README.md" ] && has_readme=""
    [ -d "$kit_path/flows" ] && has_flows=""
    
    echo "Kit: $kit_name"
    echo "  config.json: $has_config  README.md: $has_readme  flows/: $has_flows  .env.example: $has_env_example  package.json: $has_package_json"
  fi
done

Repository: Lamatic/AgentKit

Length of output: 1050


Add validation for .env.example and package.json in kit checks.

The workflow validates only config.json, README.md, and flows/ for kits, but documentation requires .env.example and package.json. Evidence shows kits already fail these requirements:

  • kits/assistant/grammar-extension/ is missing both .env.example and package.json
  • kits/embed/content-generation/ is missing package.json

Both pass the current workflow validation, violating documented requirements.

Comment thread .github/workflows/validate-pr.yml Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@d-pamneja d-pamneja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amanintech amanintech merged commit 4e2f140 into main Mar 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants